<?php

include ("config.php");

Layout::showIframeHeader($db->loadListTables());

if ($_POST["save"])
{
    foreach ($_POST["editkey"] as $k => $v) { $editkey = $k; continue; }
    
    if (!empty($_POST["editkey"][$editkey]))
    {
        if ($editkey == "dbmister_where")
        {
            $db->exeUpdate($_POST["table"], stripslashes(stripslashes($_POST["editkey"][$editkey])), $_POST["cols"]);
        }
        else
        {
            $db->exeUpdate($_POST["table"], "{$editkey} = '{$_POST["editkey"][$editkey]}'", $_POST["cols"]);
        }
        Layout::iframeAlertAndClose("Změny uloženy");
    }
    else
    {
        $db->exeInsert($_POST["table"], $_POST["cols"]);
        Layout::iframeAlertAndClose("Řádek přidán");
    }
}

FormCreator::printTableForms(FormCreator::createTableForms($db->loadDescribe($_GET["table"]),
                                                           $db->loadValues($_GET["table"], $_GET["col"], $_GET["val"])));

Layout::showIframeFooter();
?>
